package com.ruoyi.qxk.rabmq.listener;

import com.ruoyi.qxk.domain.Rescue;
import com.ruoyi.qxk.service.IRescueService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @className: HelppListenter
 * @author: xikun
 * @date: 2025/5/21 20:59
 * @Version: 1.0
 * @description:
 */
@Component
public class HelppListenter {

    @Autowired
    private IRescueService rescueService;
    //监听死信队列
    @RabbitListener(queues = "Help_queue2")
    public void HelpListener(Rescue rescue) {

        //判断订单状态
        int i = rescueService.selectStatusById(rescue.getId());
        if (i == 1) {
            System.out.println("已经接单");
        }   else if (i==0){
            int i1 = rescueService.deleteRescueById(rescue.getId());
            System.out.println(rescue.getName() +"的订单取消：超时未接单");
        }
    }
}
